/**
 * Author:beyondboy
 * Gmail:xuguoli.scau@gmail.com
 * Date: 2015-04-22
 * Time: 18:02
 */
package com.scau.beyondboy.criminalintent;
import android.content.Context;
import android.util.Log;

import java.util.ArrayList;
import java.util.UUID;
public class CrimeLab
{
    private static final String TAG ="CrimeLab" ;
    private ArrayList<Crime> mCrimes;
    private static CrimeLab mCrimeLab;
    private Context mAppContext;
    /**初始化*/
    private CrimeLab(Context appContext)
    {
        Log.i(TAG,"CrimeLab" );
        mCrimes = new ArrayList<Crime>();
        mAppContext = appContext;
        for(int i=0;i<100;i++)
        {
            Crime c=new Crime();
            c.setTitle("Crime #"+i);
            c.setSolved(i % 2 == 0);
            mCrimes.add(c);
        }
    }
    /**返回单利CrimeLab对象*/
    public static CrimeLab get(Context c)
    {
        if(mCrimeLab==null)
        {
            mCrimeLab=new CrimeLab(c.getApplicationContext());
        }
        return mCrimeLab;
    }
    /**返回Crime的集合*/
    public ArrayList<Crime> getCrimes()
    {
        return mCrimes;
    }
    /**返回Id对应的Crime对象*/
    public Crime getCrime(UUID id)
    {
        for(Crime c:mCrimes)
        {
            if(c.getId().equals(id))
            {
                return c;
            }
        }
        return null;
    }
}
